package com.jyw.system.domain.vo;

import com.jyw.system.domain.SysTeam;
import com.jyw.system.domain.SysUserTeam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 沈峻
 * @ClassName DeptTeamVo
 * @Description TODO
 * @Date 2023/9/6 15:12
 **/
@ApiModel("部门小组对象")
@Data
@NoArgsConstructor
public class DeptTeamVo {

    @ApiModelProperty("小组标识")
    private Long teamId;

    @ApiModelProperty("小组名称")
    private String teamName;

    @ApiModelProperty("小组用户")
    private List<SimpleUserVo> userList;

    public DeptTeamVo(SysTeam team, List<SysUserTeam> userTeamList) {
        setTeamId(team.getId());
        setTeamName(team.getTeamName());
        setUserList(userTeamList.stream().filter(data->data.getTeamId().equals(team.getId())).map(data->new SimpleUserVo(data)).collect(Collectors.toList()));
    }
}
